define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/integral/index',
					// add_url: 'user/intergal/add',
					// edit_url: 'user/intergal/edit',
					// // del_url: 'user/intergal/del',
     //                import_url: 'user/intergal/imports',
                    multi_url: 'user/integral/multi',
                    table: 'integral',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                            {field: 'id', title: __('Id'), sortable: true},
                            {field: 'mobile', title: __('手机号'), operate: 'LIKE'},
                            {field: 'score', title: __('使用积分'), operate: false},
							{field: 'type', title: __('类型'), searchList:{"1":__('增加'),"2":__('减少')},formatter: Table.api.formatter.normal},
							{field: 'integral', title: __('积分'),operate:false},
							{field: 'content', title: __('描述'),operate:false},
                            {field: 'createtime', title: __('添加时间'), formatter: Table.api.formatter.datetime,operate:false},
							{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
				//禁用默认搜索
				search: false,
				//启用普通表单搜索
				commonSearch: true,
				//可以控制是否默认显示搜索单表,false则隐藏,默认为false
				searchFormVisible: true,
				showSearch: false,
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
		// add: function () {
		//     Controller.api.bindevent();
		//     lonlat('','');
		// },
		// edit: function () {
		//     Controller.api.bindevent();
		//     var str = $("#c-lonlat").val();
		//     var arr = str.split(',');
		//     lonlat(arr[0],arr[1]);
		// },
        reset: function(){
            $(document).on('click','.btn-success',function(){
                Form.api.submit($("form[role=form]"),function(){
                    window.parent.location.reload();
                })
            });
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});

